<template>
  <div class="news-center">
    <client-carousel arrows="never" :url="banner" />
    <div class="news-title">
      <h2>资讯中心</h2>
    </div>
    <div class="news-content">
      <div class="news-box">
        <h1>{{ info.newsTittle || "无" }}</h1>
        <div class="new-sub-title">
          作者： {{ info.publisher || "无" }} &nbsp;&nbsp;&nbsp;&nbsp; 发布时间：{{
            info.createTime || "--"
          }}
          <el-tag>{{ info.newsTypeName || '无' }}</el-tag>
        </div>
        <div v-html="info.newsContent" class="new-body"></div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { newsDetails } from "@/api/other";
import { useRoute } from "vue-router";
import { getAssetURL } from "@/utils/load_assets";
const route = useRoute();

const bannerUrl = getAssetURL("client/news/banner.png");
const banner = ref<any>([{ url: bannerUrl }]);
const newsId = ref<any>(""); // 资讯ID

const info = ref<any>({}); // 资讯信息

onMounted(() => {
  newsId.value = route.query.newsId;
  getDetails();
});

// 获取资讯详情
const getDetails = () => {
  newsDetails(newsId.value).then((res: any) => {
    info.value = res.data;
    info.value.newsContent =  info.value.newsContent?.replaceAll('<img ','<img class="editor-img" ');
  });
};
</script>
<style scoped lang="less">
.news-center {
  width: 100%;
  min-height: calc(100vh - 400px);
  position: relative;
  .news-title {
    position: absolute;
    left: 0;
    right: 0;
    top: 140px;
    display: flex;
    justify-content: center;
    h2 {
      width: 1200px;
      line-height: 60px;
      font-size: 40px;
      font-weight: 600;
      color: #fff;
      letter-spacing: 1px;
    }
  }
  .news-content {
    display: flex;
    justify-content: center;
    background-color: #fff;
    .news-box {
      width: 1200px;
      min-height: 300px;
      h1 {
        font-size: 24px;
        font-weight: 500;
        color: #212a40;
        line-height: 32px;
        margin: 24px 0;
      }
      .new-sub-title {
        font-size: 14px;
        font-weight: 400;
        color: #6d7383;
        line-height: 20px;
        padding-bottom: 30px;
        border-bottom: 1px solid #e6e6e6;
      }
      .new-body {
        margin: 20px 0;
      }
    }
  }
}
</style>
